package com.example.mybank.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.example.mybank.entity.Account;
import org.apache.ibatis.annotations.Update;
import org.springframework.stereotype.Repository;

@Repository
public interface AccountMapper extends BaseMapper<Account> {

    @Update("UPDATE account " +
            "SET money=money-#{money} " +
            "WHERE id=#{accountID} and money>=#{money}")
    public int pay(Long accountID,Long money);

    @Update("UPDATE account " +
            "SET money=money+#{money} " +
            "WHERE id=#{accountID} ")
    public int getMoney(Long accountID,Long money);
}
